import { defineStore } from "pinia"
import { IUserInfo } from '@/api/interface'

export interface IAuthState {
	userInfo: IUserInfo
	AppID: string
}

export const useAuthStore = defineStore({
  id:'auth',
  state:() => (
    {
      userInfo:{},
      AppID:''
    } as IAuthState 
  ),
  actions: {
    saveUserInfo(data: any){
      this.$state.userInfo = data
    },
    setAppId(data: string){
      this.$state.AppID = data
    }
  },
  persist:{
    //开启数据缓存
    key:'auth',
    storage:window.localStorage,
    overwrite:true
  }
})
